home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / interp / fd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  20.7 KB  |  783 lines  |  [TEXT/ttxt]

  1. /**********************************************************************\
  2. *
  3. *  Copyright (c) 1994  Carnegie Mellon University
  4. *  All rights reserved.
  5. *  
  6. *  Use and copying of this software and preparation of derivative
  7. *  works based on this software are permitted, including commercial
  8. *  use, provided that the following conditions are observed:
  9. *  
  10. *  1. This copyright notice must be retained in full on any copies
  11. *     and on appropriate parts of any derivative works.
  12. *  2. Documentation (paper or online) accompanying any system that
  13. *     incorporates this software, or any part of it, must acknowledge
  14. *     the contribution of the Gwydion Project at Carnegie Mellon
  15. *     University.
  16. *  
  17. *  This software is made available "as is".  Neither the authors nor
  18. *  Carnegie Mellon University make any warranty about the software,
  19. *  its performance, or its conformity to any specification.
  20. *  
  21. *  Bug reports, questions, comments, and suggestions should be sent by
  22. *  E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  23. *
  24. ***********************************************************************
  25. *
  26. * $Header: fd.c,v 1.21 94/11/03 22:19:12 wlott Exp $
  27. *
  28. * This file implements an interface to file descriptors.
  29. *
  30. \**********************************************************************/
  31.  
  32. #include "../compat/std-c.h"
  33. #include "../compat/std-os.h"
  34.  
  35. #include "mindy.h"
  36. #include "list.h"
  37. #include "bool.h"
  38. #include "thread.h"
  39. #include "func.h"
  40. #include "driver.h"
  41. #include "buf.h"
  42. #include "str.h"
  43. #include "num.h"
  44. #include "obj.h"
  45. #include "def.h"
  46.  
  47. static void results(struct thread *thread, obj_t *old_sp,
  48.             int okay, obj_t result)
  49. {
  50.     thread->sp = old_sp + 2;
  51.  
  52.     if (okay < 0) {
  53.     old_sp[0] = obj_False;
  54.     old_sp[1] = make_fixnum(errno);
  55.     }
  56.     else {
  57.     old_sp[0] = result;
  58.     old_sp[1] = obj_False;
  59.     }
  60.  
  61.     do_return(thread, old_sp, old_sp);
  62. }
  63.  
  64. static void fd_close(obj_t self, struct thread *thread, obj_t *args)
  65. {
  66.     obj_t fd = args[0];
  67.  
  68.     results(thread, args-1, close(fixnum_value(fd)), obj_True);
  69. }
  70.  
  71. static obj_t fd_error_str(obj_t errno)
  72. {
  73.   return make_byte_string(strerror(fixnum_value(errno)));
  74. }
  75.  
  76. static int input_available(int fd)
  77. {
  78.     fd_set fds;
  79.     struct timeval tv;
  80.  
  81.     FD_ZERO(&fds);
  82.     FD_SET(fd, &fds);
  83.     tv.tv_sec = 0;
  84.     tv.tv_usec = 0;
  85.     return select(fd+1, &fds, NULL, NULL, &tv);
  86. }
  87.  
  88. static void fd_input_available(obj_t self, struct thread *thread, obj_t *args)
  89. {
  90.     int fd = fixnum_value(args[0]);
  91.     int res = input_available(fd);
  92.  
  93.     results(thread, args-1, res, res ? obj_True : obj_False);
  94. }
  95.  
  96. static void fd_open(obj_t self, struct thread *thread, obj_t *args)
  97. {
  98.     obj_t path = args[0];
  99.     obj_t flags = args[1];
  100.     int res;
  101.  
  102.     res = open((char *)string_chars(path), fixnum_value(flags), 0666);
  103.  
  104.     results(thread, args-1, res, make_fixnum(res));
  105. }
  106.  
  107. static void maybe_read(struct thread *thread)
  108. {
  109.     obj_t *fp = thread->fp;
  110.     int fd = fixnum_value(fp[-8]);
  111.     int nfound, res;
  112.     obj_t *old_sp;
  113.  
  114.     nfound = input_available(fd);
  115.     if (nfound < 0) {
  116.     old_sp = pop_linkage(thread);
  117.     thread->sp = old_sp + 2;
  118.     old_sp[0] = obj_False;
  119.     old_sp[1] = make_fixnum(errno);
  120.     do_return(thread, old_sp, old_sp);
  121.     }
  122.     else if (nfound == 0)
  123.     wait_for_input(thread, fd, maybe_read);
  124.     else {
  125.     res = read(fd,
  126.            buffer_data(fp[-7]) + fixnum_value(fp[-6]),
  127.            fixnum_value(fp[-5]));
  128.     
  129.     results(thread, pop_linkage(thread), res, make_fixnum(res));
  130.     }
  131. }
  132.  
  133. static void fd_read(obj_t self, struct thread *thread, obj_t *args)
  134. {
  135.     thread->sp = args + 4;
  136.     push_linkage(thread, args);
  137.     maybe_read(thread);
  138. }
  139.  
  140. static void fd_seek(obj_t self, struct thread *thread, obj_t *args)
  141. {
  142.     obj_t fd = args[0];
  143.     obj_t offset = args[1];
  144.     obj_t whence = args[2];
  145.     off_t res;
  146.  
  147.     res = lseek(fixnum_value(fd), fixnum_value(offset), fixnum_value(whence));
  148.  
  149.     results(thread, args-1, res, make_fixnum(res));
  150. }
  151.  
  152. static void fd_sync_output(obj_t self, struct thread *thread, obj_t *args)
  153. {
  154.     int res = fsync(fixnum_value(args[0]));
  155.  
  156.     if (res < 0 && errno == EINVAL)
  157.     /* EINVAL means the fd is a socket, not a file descriptor.  We don't */
  158.     /* care that you can't fsync sockets. */
  159.     results(thread, args-1, 0, obj_True);
  160.     else
  161.     results(thread, args-1, res, obj_True);
  162. }
  163.  
  164. static void maybe_write(struct thread *thread)
  165. {
  166.     obj_t *fp = thread->fp;
  167.     int fd = fixnum_value(fp[-8]);
  168.     fd_set fds;
  169.     struct timeval tv;
  170.     int nfound, res;
  171.     obj_t *old_sp;
  172.  
  173.     FD_ZERO(&fds);
  174.     FD_SET(fd, &fds);
  175.     tv.tv_sec = 0;
  176.     tv.tv_usec = 0;
  177.     nfound = select(fd+1, NULL, &fds, NULL, &tv);
  178.  
  179.     if (nfound < 0)
  180.     if (errno != EINTR) {
  181.         old_sp = pop_linkage(thread);
  182.         thread->sp = old_sp + 2;
  183.         old_sp[0] = obj_False;
  184.         old_sp[1] = make_fixnum(errno);
  185.         do_return(thread, old_sp, old_sp);
  186.     }
  187.     else
  188.         wait_for_output(thread, fd, maybe_write);
  189.     else if (nfound == 0)
  190.     wait_for_output(thread, fd, maybe_write);
  191.     else {
  192.     res = write(fd,
  193.             buffer_data(fp[-7]) + fixnum_value(fp[-6]),
  194.             fixnum_value(fp[-5]));
  195.  
  196.     results(thread, pop_linkage(thread), res, make_fixnum(res));
  197.     }
  198. }
  199.  
  200. static void fd_write(obj_t self, struct thread *thread, obj_t *args)
  201. {
  202.     thread->sp = args + 4;
  203.     push_linkage(thread, args);
  204.     maybe_write(thread);
  205. }
  206.  
  207.  
  208. /* Function to run an arbitrary program, returning file descriptors for the
  209.    program's stdin and stdout. */
  210. static void fd_exec(obj_t self, struct thread *thread, obj_t *args)
  211. {
  212.     int inpipes[2], outpipes[2], forkresult;
  213.     obj_t *oldargs;
  214.  
  215.     oldargs = args - 1;
  216.     thread->sp = args + 1;
  217.  
  218.     if (pipe(inpipes) >= 0 && pipe(outpipes) >= 0 &&
  219.     (forkresult = fork()) != -1)
  220.     {
  221.     if (forkresult == 0) {
  222.         /* This process is going to exit shortly, so we needn't be too
  223.            careful about malloc behavior, nor about the fact that we
  224.            destructively modify the command string. */
  225.         char *command = (char *)string_chars(args[0]);
  226.         char *p, **args;
  227.         int argcounter = 1;
  228.  
  229.         for (p = command; *p != 0; p++)
  230.         if (*p == ' ') {
  231.             argcounter++;
  232.             while (*(++p) == ' ');
  233.         }
  234.         args = (char **) calloc(argcounter+1, sizeof(char *));
  235.         args[0] = command;
  236.         for (p = command, argcounter = 1; *p != 0; p++) {
  237.         if (*p == ' ') {
  238.             *p = 0;
  239.             while (*(++p) == ' ');
  240.             if (*p != 0)
  241.             args[argcounter++] = p;
  242.         }
  243.         }
  244.         args[argcounter] = 0;
  245.         close(0);
  246.         dup(inpipes[0]);
  247.         close(inpipes[0]);
  248.         close(inpipes[1]);
  249.         close(1);
  250.         dup(outpipes[1]);
  251.         close(outpipes[0]);
  252.         close(outpipes[1]);
  253.         execvp(args[0], args);
  254.         /* We never get here.... */
  255.     }
  256.     close(inpipes[0]);
  257.     close(outpipes[1]);
  258.     
  259.     oldargs[0] = make_fixnum(inpipes[1]);
  260.     oldargs[1] = make_fixnum(outpipes[0]);
  261.     } else {
  262.     oldargs[0] = obj_False;
  263.     oldargs[1] = obj_False;
  264.     }
  265.  
  266.     do_return(thread, oldargs, oldargs);
  267. }
  268.  
  269.  
  270. /* Init stuff. */
  271.  
  272. void init_fd_functions(void)
  273. {
  274.     define_constant("fd-close",
  275.             make_raw_method("fd-close", list1(obj_FixnumClass),
  276.                     FALSE, obj_False, FALSE,
  277.                     list2(obj_BooleanClass, obj_ObjectClass),
  278.                     obj_False, fd_close));
  279.     define_method("fd-error-string", list1(obj_FixnumClass), FALSE,
  280.           obj_False, FALSE, obj_ObjectClass, fd_error_str);
  281.     define_constant("fd-input-available?",
  282.             make_raw_method("fd-input-available?",
  283.                     list1(obj_FixnumClass),
  284.                     FALSE, obj_False, FALSE,
  285.                     list2(obj_BooleanClass, obj_ObjectClass),
  286.                     obj_False, fd_input_available));
  287.     define_constant("fd-open",
  288.             make_raw_method("fd-open",
  289.                     list2(obj_ByteStringClass,
  290.                       obj_FixnumClass),
  291.                     FALSE, obj_False, FALSE,
  292.                     list2(obj_ObjectClass, obj_ObjectClass),
  293.                     obj_False, fd_open));
  294.     define_constant("fd-read",
  295.             make_raw_method("fd-read",
  296.                     listn(4, obj_FixnumClass,
  297.                       obj_BufferClass,
  298.                       obj_FixnumClass,
  299.                       obj_FixnumClass),
  300.                     FALSE, obj_False, FALSE,
  301.                     list2(obj_ObjectClass, obj_ObjectClass),
  302.                     obj_False, fd_read));
  303.     define_constant("fd-seek",
  304.             make_raw_method("fd-seek",
  305.                     list3(obj_FixnumClass,
  306.                       obj_FixnumClass,
  307.                       obj_FixnumClass),
  308.                     FALSE, obj_False, FALSE,
  309.                     list2(obj_ObjectClass, obj_ObjectClass),
  310.                     obj_False, fd_seek));
  311.     define_constant("fd-sync-output",
  312.             make_raw_method("fd-sync-output",
  313.                     list1(obj_FixnumClass),
  314.                     FALSE, obj_False, FALSE,
  315.                     list2(obj_BooleanClass, obj_ObjectClass),
  316.                     obj_False, fd_sync_output));
  317.     define_constant("fd-write",
  318.             make_raw_method("fd-write",
  319.                     listn(4, obj_FixnumClass,
  320.                       obj_BufferClass,
  321.                       obj_FixnumClass,
  322.                       obj_FixnumClass),
  323.                     FALSE, obj_False, FALSE,
  324.                     list2(obj_ObjectClass, obj_ObjectClass),
  325.                     obj_False, fd_write));
  326.     define_constant("fd-exec",
  327.             make_raw_method("fd-exec",
  328.                     list1(obj_ByteStringClass),
  329.                     FALSE, obj_False, FALSE,
  330.                     list2(obj_ObjectClass, obj_ObjectClass),
  331.                     obj_False, fd_exec));
  332.  
  333.     define_constant("L_SET", make_fixnum(L_SET));
  334.     define_constant("L_INCR", make_fixnum(L_INCR));
  335.     define_constant("L_XTND", make_fixnum(L_XTND));
  336.  
  337.     define_constant("FNDELAY", make_fixnum(FNDELAY));
  338. #ifdef FAPPEND
  339.     define_constant("FAPPEND", make_fixnum(FAPPEND));
  340. #else
  341.     define_constant("FAPPEND", make_fixnum(O_APPEND));
  342. #endif
  343.  
  344. #ifdef FCREAT
  345.     define_constant("FCREAT", make_fixnum(FCREAT));
  346. #else
  347.     define_constant("FCREAT", make_fixnum(O_CREAT));
  348. #endif
  349. #ifdef FTRUNC
  350.     define_constant("FTRUNC", make_fixnum(FTRUNC));
  351. #else
  352.     define_constant("FTRUNC", make_fixnum(O_TRUNC));
  353. #endif
  354. #ifdef FEXCL
  355.     define_constant("FEXCL", make_fixnum(FEXCL));
  356. #else
  357.     define_constant("FEXCL", make_fixnum(O_EXCL));
  358. #endif
  359.  
  360.     define_constant("O_RDONLY", make_fixnum(O_RDONLY));
  361.     define_constant("O_WRONLY", make_fixnum(O_WRONLY));
  362.     define_constant("O_RDWR", make_fixnum(O_RDWR));
  363.     define_constant("O_NDELAY", make_fixnum(O_NDELAY));
  364.     define_constant("O_APPEND", make_fixnum(O_APPEND));
  365.     define_constant("O_CREAT", make_fixnum(O_CREAT));
  366.     define_constant("O_TRUNC", make_fixnum(O_TRUNC));
  367.     define_constant("O_EXCL", make_fixnum(O_EXCL));
  368.  
  369.     /* This compendium of error numbers comes from Tcl. */
  370. #ifdef E2BIG
  371.     define_constant("E2BIG", make_fixnum(E2BIG)); 
  372. #endif
  373. #ifdef EACCES
  374.     define_constant("EACCES", make_fixnum(EACCES)); 
  375. #endif
  376. #ifdef EADDRINUSE
  377.     define_constant("EADDRINUSE", make_fixnum(EADDRINUSE)); 
  378. #endif
  379. #ifdef EADDRNOTAVAIL
  380.     define_constant("EADDRNOTAVAIL", make_fixnum(EADDRNOTAVAIL)); 
  381. #endif
  382. #ifdef EADV
  383.     define_constant("EADV", make_fixnum(EADV)); 
  384. #endif
  385. #ifdef EAFNOSUPPORT
  386.     define_constant("EAFNOSUPPORT", make_fixnum(EAFNOSUPPORT)); 
  387. #endif
  388. #ifdef EAGAIN
  389.     define_constant("EAGAIN", make_fixnum(EAGAIN)); 
  390. #endif
  391. #ifdef EALIGN
  392.     define_constant("EALIGN", make_fixnum(EALIGN)); 
  393. #endif
  394. #ifdef EALREADY
  395.     define_constant("EALREADY", make_fixnum(EALREADY)); 
  396. #endif
  397. #ifdef EBADE
  398.     define_constant("EBADE", make_fixnum(EBADE)); 
  399. #endif
  400. #ifdef EBADF
  401.     define_constant("EBADF", make_fixnum(EBADF)); 
  402. #endif
  403. #ifdef EBADFD
  404.     define_constant("EBADFD", make_fixnum(EBADFD)); 
  405. #endif
  406. #ifdef EBADMSG
  407.     define_constant("EBADMSG", make_fixnum(EBADMSG)); 
  408. #endif
  409. #ifdef EBADR
  410.     define_constant("EBADR", make_fixnum(EBADR)); 
  411. #endif
  412. #ifdef EBADRPC
  413.     define_constant("EBADRPC", make_fixnum(EBADRPC)); 
  414. #endif
  415. #ifdef EBADRQC
  416.     define_constant("EBADRQC", make_fixnum(EBADRQC)); 
  417. #endif
  418. #ifdef EBADSLT
  419.     define_constant("EBADSLT", make_fixnum(EBADSLT)); 
  420. #endif
  421. #ifdef EBFONT
  422.     define_constant("EBFONT", make_fixnum(EBFONT)); 
  423. #endif
  424. #ifdef EBUSY
  425.     define_constant("EBUSY", make_fixnum(EBUSY)); 
  426. #endif
  427. #ifdef ECHILD
  428.     define_constant("ECHILD", make_fixnum(ECHILD)); 
  429. #endif
  430. #ifdef ECHRNG
  431.     define_constant("ECHRNG", make_fixnum(ECHRNG)); 
  432. #endif
  433. #ifdef ECOMM
  434.     define_constant("ECOMM", make_fixnum(ECOMM)); 
  435. #endif
  436. #ifdef ECONNABORTED
  437.     define_constant("ECONNABORTED", make_fixnum(ECONNABORTED)); 
  438. #endif
  439. #ifdef ECONNREFUSED
  440.     define_constant("ECONNREFUSED", make_fixnum(ECONNREFUSED)); 
  441. #endif
  442. #ifdef ECONNRESET
  443.     define_constant("ECONNRESET", make_fixnum(ECONNRESET)); 
  444. #endif
  445. #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
  446.     define_constant("EDEADLK", make_fixnum(EDEADLK)); 
  447. #endif
  448. #ifdef EDEADLOCK
  449.     define_constant("EDEADLOCK", make_fixnum(EDEADLOCK)); 
  450. #endif
  451. #ifdef EDESTADDRREQ
  452.     define_constant("EDESTADDRREQ", make_fixnum(EDESTADDRREQ)); 
  453. #endif
  454. #ifdef EDIRTY
  455.     define_constant("EDIRTY", make_fixnum(EDIRTY)); 
  456. #endif
  457. #ifdef EDOM
  458.     define_constant("EDOM", make_fixnum(EDOM)); 
  459. #endif
  460. #ifdef EDOTDOT
  461.     define_constant("EDOTDOT", make_fixnum(EDOTDOT)); 
  462. #endif
  463. #ifdef EDQUOT
  464.     define_constant("EDQUOT", make_fixnum(EDQUOT)); 
  465. #endif
  466. #ifdef EDUPPKG
  467.     define_constant("EDUPPKG", make_fixnum(EDUPPKG)); 
  468. #endif
  469. #ifdef EEXIST
  470.     define_constant("EEXIST", make_fixnum(EEXIST)); 
  471. #endif
  472. #ifdef EFAULT
  473.     define_constant("EFAULT", make_fixnum(EFAULT)); 
  474. #endif
  475. #ifdef EFBIG
  476.     define_constant("EFBIG", make_fixnum(EFBIG)); 
  477. #endif
  478. #ifdef EHOSTDOWN
  479.     define_constant("EHOSTDOWN", make_fixnum(EHOSTDOWN)); 
  480. #endif
  481. #ifdef EHOSTUNREACH
  482.     define_constant("EHOSTUNREACH", make_fixnum(EHOSTUNREACH)); 
  483. #endif
  484. #ifdef EIDRM
  485.     define_constant("EIDRM", make_fixnum(EIDRM)); 
  486. #endif
  487. #ifdef EINIT
  488.     define_constant("EINIT", make_fixnum(EINIT)); 
  489. #endif
  490. #ifdef EINPROGRESS
  491.     define_constant("EINPROGRESS", make_fixnum(EINPROGRESS)); 
  492. #endif
  493. #ifdef EINTR
  494.     define_constant("EINTR", make_fixnum(EINTR)); 
  495. #endif
  496. #ifdef EINVAL
  497.     define_constant("EINVAL", make_fixnum(EINVAL)); 
  498. #endif
  499. #ifdef EIO
  500.     define_constant("EIO", make_fixnum(EIO)); 
  501. #endif
  502. #ifdef EISCONN
  503.     define_constant("EISCONN", make_fixnum(EISCONN)); 
  504. #endif
  505. #ifdef EISDIR
  506.     define_constant("EISDIR", make_fixnum(EISDIR)); 
  507. #endif
  508. #ifdef EISNAME
  509.     define_constant("EISNAM", make_fixnum(EISNAM)); 
  510. #endif
  511. #ifdef ELBIN
  512.     define_constant("ELBIN", make_fixnum(ELBIN)); 
  513. #endif
  514. #ifdef EL2HLT
  515.     define_constant("EL2HLT", make_fixnum(EL2HLT)); 
  516. #endif
  517. #ifdef EL2NSYNC
  518.     define_constant("EL2NSYNC", make_fixnum(EL2NSYNC)); 
  519. #endif
  520. #ifdef EL3HLT
  521.     define_constant("EL3HLT", make_fixnum(EL3HLT)); 
  522. #endif
  523. #ifdef EL3RST
  524.     define_constant("EL3RST", make_fixnum(EL3RST)); 
  525. #endif
  526. #ifdef ELIBACC
  527.     define_constant("ELIBACC", make_fixnum(ELIBACC)); 
  528. #endif
  529. #ifdef ELIBBAD
  530.     define_constant("ELIBBAD", make_fixnum(ELIBBAD)); 
  531. #endif
  532. #ifdef ELIBEXEC
  533.     define_constant("ELIBEXEC", make_fixnum(ELIBEXEC)); 
  534. #endif
  535. #ifdef ELIBMAX
  536.     define_constant("ELIBMAX", make_fixnum(ELIBMAX)); 
  537. #endif
  538. #ifdef ELIBSCN
  539.     define_constant("ELIBSCN", make_fixnum(ELIBSCN)); 
  540. #endif
  541. #ifdef ELNRNG
  542.     define_constant("ELNRNG", make_fixnum(ELNRNG)); 
  543. #endif
  544. #ifdef ELOOP
  545.     define_constant("ELOOP", make_fixnum(ELOOP)); 
  546. #endif
  547. #ifdef EMFILE
  548.     define_constant("EMFILE", make_fixnum(EMFILE)); 
  549. #endif
  550. #ifdef EMLINK
  551.     define_constant("EMLINK", make_fixnum(EMLINK)); 
  552. #endif
  553. #ifdef EMSGSIZE
  554.     define_constant("EMSGSIZE", make_fixnum(EMSGSIZE)); 
  555. #endif
  556. #ifdef EMULTIHOP
  557.     define_constant("EMULTIHOP", make_fixnum(EMULTIHOP)); 
  558. #endif
  559. #ifdef ENAMETOOLONG
  560.     define_constant("ENAMETOOLONG", make_fixnum(ENAMETOOLONG)); 
  561. #endif
  562. #ifdef ENAVAIL
  563.     define_constant("ENAVAIL", make_fixnum(ENAVAIL)); 
  564. #endif
  565. #ifdef ENET
  566.     define_constant("ENET", make_fixnum(ENET)); 
  567. #endif
  568. #ifdef ENETDOWN
  569.     define_constant("ENETDOWN", make_fixnum(ENETDOWN)); 
  570. #endif
  571. #ifdef ENETRESET
  572.     define_constant("ENETRESET", make_fixnum(ENETRESET)); 
  573. #endif
  574. #ifdef ENETUNREACH
  575.     define_constant("ENETUNREACH", make_fixnum(ENETUNREACH)); 
  576. #endif
  577. #ifdef ENFILE
  578.     define_constant("ENFILE", make_fixnum(ENFILE)); 
  579. #endif
  580. #ifdef ENOANO
  581.     define_constant("ENOANO", make_fixnum(ENOANO)); 
  582. #endif
  583. #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
  584.     define_constant("ENOBUFS", make_fixnum(ENOBUFS)); 
  585. #endif
  586. #ifdef ENOCSI
  587.     define_constant("ENOCSI", make_fixnum(ENOCSI)); 
  588. #endif
  589. #ifdef ENODATA
  590.     define_constant("ENODATA", make_fixnum(ENODATA)); 
  591. #endif
  592. #ifdef ENODEV
  593.     define_constant("ENODEV", make_fixnum(ENODEV)); 
  594. #endif
  595. #ifdef ENOENT
  596.     define_constant("ENOENT", make_fixnum(ENOENT)); 
  597. #endif
  598. #ifdef ENOEXEC
  599.     define_constant("ENOEXEC", make_fixnum(ENOEXEC)); 
  600. #endif
  601. #ifdef ENOLCK
  602.     define_constant("ENOLCK", make_fixnum(ENOLCK)); 
  603. #endif
  604. #ifdef ENOLINK
  605.     define_constant("ENOLINK", make_fixnum(ENOLINK)); 
  606. #endif
  607. #ifdef ENOMEM
  608.     define_constant("ENOMEM", make_fixnum(ENOMEM)); 
  609. #endif
  610. #ifdef ENOMSG
  611.     define_constant("ENOMSG", make_fixnum(ENOMSG)); 
  612. #endif
  613. #ifdef ENONET
  614.     define_constant("ENONET", make_fixnum(ENONET)); 
  615. #endif
  616. #ifdef ENOPKG
  617.     define_constant("ENOPKG", make_fixnum(ENOPKG)); 
  618. #endif
  619. #ifdef ENOPROTOOPT
  620.     define_constant("ENOPROTOOPT", make_fixnum(ENOPROTOOPT)); 
  621. #endif
  622. #ifdef ENOSPC
  623.     define_constant("ENOSPC", make_fixnum(ENOSPC)); 
  624. #endif
  625. #ifdef ENOSR
  626.     define_constant("ENOSR", make_fixnum(ENOSR)); 
  627. #endif
  628. #if defined(ENOSTR) && (!defined(ENOTTY) || (ENOTTY != ENOSTR))
  629.     define_constant("ENOSTR", make_fixnum(ENOSTR)); 
  630. #endif
  631. #ifdef ENOSYM
  632.     define_constant("ENOSYM", make_fixnum(ENOSYM)); 
  633. #endif
  634. #ifdef ENOSYS
  635.     define_constant("ENOSYS", make_fixnum(ENOSYS)); 
  636. #endif
  637. #ifdef ENOTBLK
  638.     define_constant("ENOTBLK", make_fixnum(ENOTBLK)); 
  639. #endif
  640. #ifdef ENOTCONN
  641.     define_constant("ENOTCONN", make_fixnum(ENOTCONN)); 
  642. #endif
  643. #ifdef ENOTDIR
  644.     define_constant("ENOTDIR", make_fixnum(ENOTDIR)); 
  645. #endif
  646. #if defined(ENOTEMPTY) && (!defined(EEXIST) || (ENOTEMPTY != EEXIST))
  647.     define_constant("ENOTEMPTY", make_fixnum(ENOTEMPTY)); 
  648. #endif
  649. #ifdef ENOTNAM
  650.     define_constant("ENOTNAM", make_fixnum(ENOTNAM)); 
  651. #endif
  652. #ifdef ENOTSOCK
  653.     define_constant("ENOTSOCK", make_fixnum(ENOTSOCK)); 
  654. #endif
  655. #ifdef ENOTTY
  656.     define_constant("ENOTTY", make_fixnum(ENOTTY)); 
  657. #endif
  658. #ifdef ENOTUNIQ
  659.     define_constant("ENOTUNIQ", make_fixnum(ENOTUNIQ)); 
  660. #endif
  661. #ifdef ENXIO
  662.     define_constant("ENXIO", make_fixnum(ENXIO)); 
  663. #endif
  664. #ifdef EOPNOTSUPP
  665.     define_constant("EOPNOTSUPP", make_fixnum(EOPNOTSUPP)); 
  666. #endif
  667. #ifdef EPERM
  668.     define_constant("EPERM", make_fixnum(EPERM)); 
  669. #endif
  670. #ifdef EPFNOSUPPORT
  671.     define_constant("EPFNOSUPPORT", make_fixnum(EPFNOSUPPORT)); 
  672. #endif
  673. #ifdef EPIPE
  674.     define_constant("EPIPE", make_fixnum(EPIPE)); 
  675. #endif
  676. #ifdef EPROCLIM
  677.     define_constant("EPROCLIM", make_fixnum(EPROCLIM)); 
  678. #endif
  679. #ifdef EPROCUNAVAIL
  680.     define_constant("EPROCUNAVAIL", make_fixnum(EPROCUNAVAIL)); 
  681. #endif
  682. #ifdef EPROGMISMATCH
  683.     define_constant("EPROGMISMATCH", make_fixnum(EPROGMISMATCH)); 
  684. #endif
  685. #ifdef EPROGUNAVAIL
  686.     define_constant("EPROGUNAVAIL", make_fixnum(EPROGUNAVAIL)); 
  687. #endif
  688. #ifdef EPROTO
  689.     define_constant("EPROTO", make_fixnum(EPROTO)); 
  690. #endif
  691. #ifdef EPROTONOSUPPORT
  692.     define_constant("EPROTONOSUPPORT", make_fixnum(EPROTONOSUPPORT)); 
  693. #endif
  694. #ifdef EPROTOTYPE
  695.     define_constant("EPROTOTYPE", make_fixnum(EPROTOTYPE)); 
  696. #endif
  697. #ifdef ERANGE
  698.     define_constant("ERANGE", make_fixnum(ERANGE)); 
  699. #endif
  700. #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
  701.     define_constant("EREFUSED", make_fixnum(EREFUSED)); 
  702. #endif
  703. #ifdef EREMCHG
  704.     define_constant("EREMCHG", make_fixnum(EREMCHG)); 
  705. #endif
  706. #ifdef EREMDEV
  707.     define_constant("EREMDEV", make_fixnum(EREMDEV)); 
  708. #endif
  709. #ifdef EREMOTE
  710.     define_constant("EREMOTE", make_fixnum(EREMOTE)); 
  711. #endif
  712. #ifdef EREMOTEIO
  713.     define_constant("EREMOTEIO", make_fixnum(EREMOTEIO)); 
  714. #endif
  715. #ifdef EREMOTERELEASE
  716.     define_constant("EREMOTERELEASE", make_fixnum(EREMOTERELEASE)); 
  717. #endif
  718. #ifdef EROFS
  719.     define_constant("EROFS", make_fixnum(EROFS)); 
  720. #endif
  721. #ifdef ERPCMISMATCH
  722.     define_constant("ERPCMISMATCH", make_fixnum(ERPCMISMATCH)); 
  723. #endif
  724. #ifdef ERREMOTE
  725.     define_constant("ERREMOTE", make_fixnum(ERREMOTE)); 
  726. #endif
  727. #ifdef ESHUTDOWN
  728.     define_constant("ESHUTDOWN", make_fixnum(ESHUTDOWN)); 
  729. #endif
  730. #ifdef ESOCKTNOSUPPORT
  731.     define_constant("ESOCKTNOSUPPORT", make_fixnum(ESOCKTNOSUPPORT)); 
  732. #endif
  733. #ifdef ESPIPE
  734.     define_constant("ESPIPE", make_fixnum(ESPIPE)); 
  735. #endif
  736. #ifdef ESRCH
  737.     define_constant("ESRCH", make_fixnum(ESRCH)); 
  738. #endif
  739. #ifdef ESRMNT
  740.     define_constant("ESRMNT", make_fixnum(ESRMNT)); 
  741. #endif
  742. #ifdef ESTALE
  743.     define_constant("ESTALE", make_fixnum(ESTALE)); 
  744. #endif
  745. #ifdef ESUCCESS
  746.     define_constant("ESUCCESS", make_fixnum(ESUCCESS)); 
  747. #endif
  748. #ifdef ETIME
  749.     define_constant("ETIME", make_fixnum(ETIME)); 
  750. #endif
  751. #ifdef ETIMEDOUT
  752.     define_constant("ETIMEDOUT", make_fixnum(ETIMEDOUT)); 
  753. #endif
  754. #ifdef ETOOMANYREFS
  755.     define_constant("ETOOMANYREFS", make_fixnum(ETOOMANYREFS)); 
  756. #endif
  757. #ifdef ETXTBSY
  758.     define_constant("ETXTBSY", make_fixnum(ETXTBSY)); 
  759. #endif
  760. #ifdef EUCLEAN
  761.     define_constant("EUCLEAN", make_fixnum(EUCLEAN)); 
  762. #endif
  763. #ifdef EUNATCH
  764.     define_constant("EUNATCH", make_fixnum(EUNATCH)); 
  765. #endif
  766. #ifdef EUSERS
  767.     define_constant("EUSERS", make_fixnum(EUSERS)); 
  768. #endif
  769. #ifdef EVERSION
  770.     define_constant("EVERSION", make_fixnum(EVERSION)); 
  771. #endif
  772. #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
  773.     define_constant("EWOULDBLOCK", make_fixnum(EWOULDBLOCK)); 
  774. #endif
  775. #ifdef EXDEV
  776.     define_constant("EXDEV", make_fixnum(EXDEV)); 
  777. #endif
  778. #ifdef EXFULL
  779.     define_constant("EXFULL", make_fixnum(EXFULL)); 
  780. #endif
  781.     
  782. }
  783.